<div class=" pad_top">
    <span ng-if="user.email!==profile.email">
        <button type="button" ng-click="editClick(true, false, false)" class="ice-button">
            <i style="font-size: 14px" class="blue fa fa-envelope"></i> Send Message
        </button>
        &nbsp;
    </span>
    <span ng-if="user.email===profile.email||user.isAdmin">
        <button type="button" ng-click="editClick(false, true, false)" class="ice-button">
            <i style="font-size: 14px" class="blue fa fa-edit"></i> Edit Profile
        </button>
        &nbsp;
    </span>
    <span ng-if="passwordChangeAllowed">
        <button type="button" ng-click="editClick(false, false, true)" class="ice-button">
            <i style="font-size: 14px" class="blue fa fa-key"></i> Change Password
        </button>
    </span>
</div>

<div class=" pad_top" ng-show="!showChangePassword && !showEditProfile && !showSendMessage">
    <i style="color: #999;">{{profile.description || 'No profile description provided.'}}</i>
</div>

<div class=" margin-top-10 panel panel-default font-95em" ng-if="showEditProfile" ng-init="switchtoEditMode()">
    <form class="panel-body" role="form" ng-submit="updateProfile()">
        <div class="col-md-2 pad-top-5">
            <span style="white-space:nowrap">First name <span class="required">*</span> </span>
        </div>

        <div class="col-md-10 pad-top-5">
            <input type="text" class="input_box" ng-model="editProfile.firstName" maxlength="125" style="width: 235px;">
        </div>
        <div class="col-md-2 pad-top-5">
            <span style="white-space:nowrap">Last name <span class="required">*</span></span>
        </div>

        <div class="col-md-10 pad-top-5">
            <input type="text" class="input_box" ng-model="editProfile.lastName" maxlength="125" style="width: 235px;">
        </div>
        <div class="col-md-2 pad-top-5">
            <span style="white-space:nowrap">Institution</span>
        </div>
        <div class="col-md-10 pad-top-5">
            <input type="text" class="input_box" ng-model="editProfile.institution" maxlength="125"
                   style="width: 235px;">
        </div>

        <div class="col-md-2 pad-top-5">
            <span style="white-space:nowrap">About</span>
        </div>
        <div class="col-md-10 pad-top-5">
            <textarea rows="3" cols="30" ng-model="editProfile.description" class="input_box"
                      placeholder="Enter profile description"></textarea>
        </div>

        <br>

        <div class="col-xs-offset-2 col-md-10 pad_top">
            <button type="submit" class="btn btn-xs btn-primary">Save</button>
            <button type="button" ng-click="editClick(false, false, false)" class="btn btn-xs btn-default">Cancel
            </button>
        </div>
    </form>
</div>

<div class=" margin-top-10 panel panel-default" ng-if="showChangePassword">
    <div class="panel-body">
        <h4>Change password
            <small ng-if="userId != user.id"><i class="fa fa-exclamation-circle fa-fw orange"></i>Changing another
                user's password
            </small>
        </h4>

        <div class="alert alert-danger" style="width: 435px; padding: 8px" ng-if="changePasswordError">
            <i style="font-size: 15px" class="fa fa-exclamation-triangle"></i>
            <span class="font-90em">{{changePasswordError}}</span>
        </div>

        <div class="alert alert-info" style="width: 435px; padding: 8px"
             ng-if="passwordChangeSuccess&&!changePasswordError">
            <i style="font-size: 15px" class="fa fa-info-circle"></i>
            <span class="font-90em">Password successfully changed</span>
        </div>

        <form class="font-95em" role="form" ng-submit="updatePassword()" ng-if="!passwordChangeSuccess">
            <!--<div class="col-md-2 pad-top-5">-->
            <!--<span style="white-space:nowrap">Verify your password <span class="required">*</span> </span>-->
            <!--</div>-->
            <!--<div class="col-md-10 pad-top-5">-->
            <!--<input type="password" ng-model="changePass.current" ng-change="currentError=false"-->
            <!--ng-class="{'input_box':!currentError, 'input_box_error':currentError}" ng-trim="true"-->
            <!--maxlength="125" style="width: 205px;">-->
            <!--</div>-->

            <div class="col-md-12">&nbsp;</div>

            <div class="col-md-2 pad-top-5">
                <span style="white-space:nowrap">New password <span class="required">*</span></span>
            </div>
            <div class="col-md-10 pad-top-5">
                <input type="password" ng-model="changePass.new" ng-change="noMatch=false;newPassError=false"
                       ng-class="{'input_box':!noMatch&&!newPassError, 'input_box_error':noMatch||newPassError}"
                       maxlength="125" style="width: 205px;" ng-trim="true">
            </div>

            <div class="col-md-2 pad-top-5">
                <span style="white-space:nowrap">Confirm new password <span class="required">*</span></span>
            </div>
            <div class="col-md-10 pad-top-5">
                <input type="password" ng-model="changePass.new2" class="input_box" maxlength="125"
                       style="width: 205px;">
                <i class="fa fa-fw fa-check green font-12em"
                   ng-if="changePass.new2 && changePass.new === changePass.new2"></i>
                <i class="fa fa-fw fa-minus-circle red font-12em" uib-tooltip="Passwords do not match"
                   ng-if="changePass.new2 && changePass.new !== changePass.new2"></i>
            </div>

            <br>

            <div class="col-xs-offset-2 col-md-10 pad_top">
                <button type="submit" class="btn btn-xs btn-primary"
                        ng-disabled="!changePass.new2 || !changePass.new">Update
                </button>
                <button type="button" ng-click="editClick(false, false, false)" class="btn btn-xs btn-default">Cancel
                </button>
            </div>
        </form>
    </div>
</div>